<? 
	$accesslevel=1;
	$title="Edit Profiles";
	require("required/dbconnect.php");
	require("required/share_function.php");
	$_SESSION['pid']=-1;
	require("required/header.php"); 
	
	$getdata=mysql_query("select * from os_member where id=".$member_id);
	$a=mysql_fetch_array($getdata,MYSQL_ASSOC);
?>
<script type="text/javascript" src="required/calendarDateInput.js"></script>
<script language="JavaScript" type="text/javascript" src="required/js/goAjax.js"></script>
<script language="javascript">
	
	
	
	
	function changeState(countryId) {
		
		if(countryId!=""){
			changeContent('required/js/ajax_place.php?country_id='+countryId+'&tag=state','divState');
			setTimeout("getAreaType("+countryId+")",500);
		}
	}
	
	function getAreaType(countryId) {
	
		changeContent('required/js/getAreaType.php?country_id='+countryId,'divAreaType');
		
	}
	
	function formvalidate(frm)
	{
		if(document.frm1.name.value=="")
		{
			alert("Please enter your name");
			document.frm1.name.focus();
			return false;
		}
		
		if(document.frm1.last_name.value=="")
		{
			alert("Please enter your last name");
			document.frm1.last_name.focus();
			return false;
		}
		
		
		if(document.frm1.country.value=="")
		{
			alert("Please select your country");
			document.frm11.country.focus();
			return false;
		}
		if(document.frm1.state.value=="")
		{
			alert("Please select your state");
			document.frm1.state.focus();
			return false;
		}
		if(document.frm1.hpnumber.value=="")
		{
			alert("Please enter your contact number");
			document.frm1.hpnumber.focus();
			return false;
		}
		
		return true;
	}
	
</script>


		
			<table width="100%" cellpadding="6" cellspacing="0">
				<tr>
					<td class="page_title_bar">
					Edit Profiles
							
					</td>
										
				</tr>	
				<tr>
					<td align="center">
                    	<form action="os_editdetails2.php" method="post" name="frm1" onSubmit="return formvalidate(this)">
						<table width="90%" height="100%">
							
                              	<tr valign="top">
									<td width="28%">Email</td><td>:</td><td width="71%"><?= $a['email'] ?></td>
								</tr>
                                <?
									if(strtoupper($a['member_type'])!="M")
									{
									
								?>
                                <tr valign="top">
									<td width="28%">Membership Number</td><td>:</td><td><input type="text" class='text' size="30" maxlength="50" name="membership_number" value="<?= $a['membership_number'] ?>"></td>
								</tr>
                                <? }else{ ?>
								<tr valign="top">
									<td width="28%">Membership Number</td><td>:</td><td><?= $a['membership_number'] ?></td>
								</tr>
                                <input type="hidden" name="membership_number" value="<?= $a['membership_number'] ?>">
								<? } ?>
								<tr>
									<td height="20" colspan="3"><br><br><strong>Personal Information</strong></td>
								</tr>
								<tr>
									<td>First Name<font color="#FF0000">*</font></td><td>:</td><td><input type="text" class='text' size="30" maxlength="50" name="name" value="<?= $a['name'] ?>"></td>
								</tr>
                                <tr>
									<td>Last Name<font color="#FF0000">*</font></td><td>:</td><td><input type="text" class='text' size="30" maxlength="50" name="last_name" value="<?= $a['last_name'] ?>"></td>
								</tr>
								<tr>
									<td height="20" colspan="3"><br><br><strong>Personal Information</strong></td>
								</tr>
								<tr>
									<td>First Name<font color="#FF0000">*</font></td><td>:</td><td><input type="text" class='text' size="30" maxlength="50" name="name" value="<?= $a['name'] ?>"></td>
								</tr>
                                <tr>
									<td>Last Name<font color="#FF0000">*</font></td><td>:</td><td><input type="text" class='text' size="30" maxlength="50" name="last_name" value="<?= $a['last_name'] ?>"></td>
								</tr>
								<?
									if($a['gender']=="male")
									{
										$malechk="checked";
										$femalechk="";
									}
									else
									{
										$malechk="";
										$femalechk="checked";
									}
								?>
								<tr>
									<td>Gender</td><td>:</td><td><input type="radio" name="sex" value="male" <?= $malechk ?>>Male<input type="radio" name="sex" value="female" <?= $femalechk ?>>Female</td>
								</tr>
								<tr>
									<td>Birth date</td><td>:</td>
									<td>
									<script>
										var go_date="<?= $a['dob'] ?>" ;
										DateInput('dob', true, 'YYYY-MM-DD',go_date )
									</script>
									</td>
								</tr>
								<tr>
									<td>IC number</td><td>:</td><td><input type="text" class='text' size="20" maxlength="50" name="icnumber" value="<?= $a['icnumber'] ?>"></td>
								</tr>
								<tr>
									<td height="20" colspan="3"><br><br>	<strong>Contact Information</strong></td>
								</tr>
								<tr>
									<td>Address</td><td>:</td><td><input type="text" class='text' size="40" maxlength="100" name="address1" value="<?= $a['address1'] ?>"></td>
								</tr>
								<tr>
									<td colspan="2"></td><td><input type="text" class='text' size="40" maxlength="100" name="address2" value="<?= $a['address2'] ?>"></td>
								</tr>
								<tr>
									<td>Postcode</td><td>:</td><td><input type="text" class='text' size="7" maxlength="15" name="postcode" value="<?= $a['postcode'] ?>"></td>
								</tr>
								<tr>
									<td>City</td><td>:</td><td><input type="text" class='text' size="20" maxlength="15" name="city" value="<?= $a['city'] ?>"></td>
								</tr>
								
								<tr valign="top">
								<td>Country</td><td>:</td>
								<td width="1507">
								
								<?
									$get_place=mysql_query("select * from os_country where status=1 order by main_country desc,engname asc");
									
									if($a['country']!=0)
									{
									
										$get_country=mysql_query("select * from os_country where id=".$a['country'])or die(mysql_error());
										$country=mysql_result($get_country,0,"engname");
										
										if(mysql_result($get_country,0,'area_type')=="")
										{
											$area_type="State";
										}else{
											$area_type=mysql_result($get_country,0,'area_type');
										}
									}
									else
									{
										
										$area_type="State";
									} 
								?>
								<select name="country" class="text" onChange="changeState(this.value)">
									
								<? 
									while($s=mysql_fetch_array($get_place,MYSQL_ASSOC))
									{
											if($s['id']==$a['country'])
                                            {
                                                $desslt="selected";
                                            }
                                            else
                                            {
                                                $desslt="";
                                            }
                                            
                                    ?>
                                        <option value="<?= $s['id'] ?>" <?= $desslt ?>><?= $s['engname'] ?></option>
								<? 
										
									}
								?>
								</select>
								</td>
							  </tr>
								<tr>
								<td><div id="divAreaType"><?= $area_type ?></div></td><td>:</td>
								<td>
								<div id="divState">
								<?
									$get_place=mysql_query("select * from os_state where country_code=".$a['country']." order by order_id asc");
								?>
								<select name="state" class="text">
									<option value="">Please select</option>
								<? 
									while($s=mysql_fetch_array($get_place,MYSQL_ASSOC))
									{
										if($s['id']==$a['state'])
										{
											$sslt="selected";
										}
										else
										{
											$sslt="";
										}	
								?>
									<option <?= $sslt ?> value="<?= $s['id'] ?>"><?= $s['name_eng'] ?></option>
								<? 
										
									}
								?>
								</select>
								</div>
								</td>
								</tr>
								<tr>
								<tr>
									<td>Contact number<font color="#FF0000">*</font></td><td>:</td><td><input type="text" class='text' size="20" maxlength="20" name="hpnumber" value="<?= $a['hpnumber'] ?>"><br></td>
								</tr>
								<tr>
									<td>Fax</td><td>:</td><td><input type="text" class='text' size="20" maxlength="20" name="fax" value="<?= $a['fax'] ?>"><br></td>
								</tr>
                      	       	<tr>
									<td colspan="3" align="center"><input type="submit" value="Submit" class="button" name="btnsubmit">
							
									<input type="button" value="Back" onclick="window.open('os_viewdetails.php','_self')" class="button">
									</td>
								</tr>	
								
							</table>
                            </form>
						</td>
					</tr>
				</table>
			
<? require("required/footer.php"); ?>